
<%@ page import="pc.system.*,wstrader.*,wstrader.task.*" %>

<%
    Users user = Trader.getUser(request.getParameter("uid"));
	
        if (user == null || !user.Authenticated()) {
                response.sendRedirect("logon.jsp");	
                return;
        }
        wstrader.task.trade.Fixation ftask = user.trade.fixation;
        wstrader.task.trade.fixation.Contract task = user.trade.fixation.contract;
        ((Tasks)ftask.getOwner()).clearFocus();
        ftask.setFocus(true);
        //ftask.forwardToChild(user.getuid());
        //Trader.window_width = "90%";	
        String view = request.getParameter("view");
        String contracts = request.getParameter("contracts");

        if (view==null) view ="0";
        if (contracts==null) contracts ="0";
        ResultSet rs;
%>

<%@include file="../header.jsp"%>

<%
        //long focused_id = task.doTask();
        //if (focused_id <= 0) focused_id = 1;
        //Record rc   = task.getRecord("purchase_contract",focused_id);
%>

<link href="style.css" rel="stylesheet" type="text/css">

<script language="javascript">
    
    $(document).ready(function(){
        getTableData();
    });
    
    function getTableData(){
        var cnt_type = $("#cnt_type").val();        
        var buyer_seller = $("#buyer_seller").val();
        var status = $("#status").val();
        var terminal_market = $("#terminal_market").val();
        var ter_mth = $("#ter_mth").val();
        var status = $("#status").val();
        var uid = $("#uid").val();
        //var table_length = $("#table_length").val();
        var data = "cnt_type=" + cnt_type + "&buyer_seller=" + buyer_seller + "&status=" + status + "&ter_mth=" + ter_mth + "&terminal_market=" + terminal_market + "&uid=" + uid;
        $.ajax({
            type: "GET",
            url: "trade.fixation.contract.ajax-source.jsp",
            data: data,
            success: function(msg){
                $("#table_data").html(msg);
            }
        });        
    }
    
    function doFilter()
    {
        var form = document.formMain;
        form.action = "trade.fixation.jsp";
        form.submit();
    }

    function clickCardView(row)
    {
        var form = document.formMain;
        form.action = "trade.fixation.contract.card.jsp";
        form.submit();	
    }

    function cardViewClick(row)
    {
        var form = document.formMain;
        form.contracts.value = row.id;
        dblClick(row);
    }
</script>
<style type="text/css">
    <!--
    .style3 {font-family: Arial}
    .style6 {font-size: 12px}
    -->
</style>
<form action="" method="post" name="formMain" id="formMain">
    <div id="logo">
        <img src="images/pricefixation.jpg" width="300" height="24">
    </div>
    <fieldset style=" background: #eee; margin-bottom: 20px; margin-top: 20px;">
        <span class="style2 style3" style="font-weight: bold;">Contract Type </span>
        <select id="cnt_type" style="font-size: 11px" onchange="getTableData()">
            <option value="0" selected>All</option>
            <option value="P">PURCHASE</option>
            <option value="S">SALES</option>
            <%task.getResponse().setSelected("cnt_type");%>
        </select>
        <span class="style2 style3" style="font-weight: bold;">Buyer/Seller</span>
        <select id="buyer_seller" style="font-size: 11px" onchange="getTableData()">
            <option value="0" selected>All</option>
            <%
                            task.getResponse().setOption(task.getCtSupplierBuyer());
                            task.getResponse().setSelected("buyer_seller");
            %>
        </select>
        <span class="style2 style3" style="font-weight: bold;">Market </span>
        <select id="terminal_market" style="font-size: 11px" onchange="getTableData()">
            <option value="0" selected>All</option>
            <option value="NYC">NYC</option>
            <option value="LIFFE">LIFFE</option>
            <%task.getResponse().setSelected("terminal_market");%>
        </select>
        <span class="style2 style3" style="font-weight: bold;">Month </span>
        <select id="ter_mth" style="font-size: 11px" onchange="getTableData()">
            <%@include file="include/TerminalMonthList.jsp"%>
        </select>
        <span class="style2 style3" style="font-weight: bold;">Status </span>
        <select id="status" style="font-size: 11px" onchange="getTableData()">
            <option value="0" selected>All</option>
            <option value="1">Pending</option>
            <option value="2">Complete</option>
            <%task.getResponse().setSelected("status");%>
        </select>
    </fieldset>
    <div id="table_data"></div>
    <table width="100%"  border="0" cellspacing="0" cellpadding="0">      
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="right" valign="middle">&nbsp;&nbsp;</td>
            <td align="right" valign="middle">&nbsp;</td>
            <td align="center" valign="middle">&nbsp;</td>
            <td align="right" valign="middle"><img src="images/cardview.jpg" width="55" height="18" onClick="clickCardView();">&nbsp;</td>
        </tr>
    </table>
    <% 
            System.out.println("View:-" + view);
            if (view.compareTo("1")==0)
            { 
    %>	  
    <script>
        dblClick();
    </script>
    <%
            }
    %> 
    <input type="hidden" name="uid"        id="uid"       value="<%=user.getuid()%>">
    <input type="hidden" name="task_id"    id = "task_id"   value="0">
    <input name="type" type="hidden" id="type">
    <input name="contracts" type="hidden" id="contracts" value="<%=contracts%>"> 
</form>
<%@include file="../footer.jsp"%>

